const Controller = require("egg").Controller;
const room = "default_room";
let arr = [];
class ChatController extends Controller {
  async index() {
    const { app, socket, logger, helper } = this.ctx;
    const nsp = app.io.of("/");
    let message = this.ctx.args[0];
    arr.push(this.ctx.args[0]);

    nsp.adapter.clients([room], (err, clients) => {});
    message.time = +new Date();
    nsp.emit("res", arr);
    // nsp.to(room).emit("res", message);
  }
}

module.exports = ChatController;
